package com.guigu.www.controller;

import com.github.pagehelper.PageInfo;
import com.guigu.www.pojo.PageVo;
import com.guigu.www.pojo.PayDetails;
import com.guigu.www.service.PayDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class PayDetailsController {

    //获取sercice
    @Autowired
    PayDetailsService payDetailsService;
    //根据当前出库单号查询要出库的产品
    @RequestMapping("/queryBypayDetailsByid.action")
    public PayDetails queryBypayDetailsByid(String productId, int id){
        return payDetailsService.queryBypayDetailsByid(productId,id);
    }


    //根据当前出库编号 父id查询
    @RequestMapping("/updatepayDetailsfuid.action")
    public Map updatepayDetailsfuid(String productId,int id){
        //创建map
        Map map=new HashMap();
        //调用方法
        boolean b=payDetailsService.updatepayDetailsfuid(productId,id);
       //判断
       map.put("msg","调度失败");
        if(b){
            map.put("msg","调度成功");
        }
        return  map;
    }
    //根据产品编号 父id查询
    @RequestMapping("/queryBypayDetalisByid.action")
    public PayDetails queryBypayDetalisByid(int id,String productId){
        return payDetailsService.queryBypayDetalisByid(id,productId);
    }

    //查询出库明细
    @RequestMapping("/querypayBydynamicinventiryall.action")
    public PageVo<PayDetails> querypayBydynamicinventiryall(@RequestParam(value = "pageno",defaultValue = "1") int pageno,@RequestParam(value = "pagesize",defaultValue = "5") int pagesize,String productId){

        //创建pagevo
        PageVo<PayDetails> pageVo=new PageVo<PayDetails>();
        //调用方法
        PageInfo<PayDetails> page=payDetailsService.querypayBydynamicinventiryall(pageno,pagesize,productId);
        pageVo.setTotal(page.getTotal());
        pageVo.setRows(page.getList());
        return pageVo;
    }
}
